<?php
/**
 * Created by PhpStorm.
 * User: Yieong
 * Date: 14/11/19
 * Time: 下午8:12
 */

class ModNoticeTemplet extends Model {

    protected $table = 'notice_templet';

    // 表名
    public function tableName(){
        return $this->table;
    }

    public static function model($className=__CLASS__){
        return parent::model($className);
    }

    public function getDbConnection(){
        return Yii::app()->dbOss;
    }

    public function select($params){
        $where  = ' WHERE platform=:platform AND game=:game ';
        $args   = array(
            ':platform' => 'test',
            ':game'     => $params['g']
        );

        if(!empty($params['name'])){
            $where .= ' AND name LIKE :name ';
            $args[':name'] = '%'.$params['name'].'%';
        }


        $sql = "SELECT * FROM {$this->table} {$where} ORDER BY create_time DESC";

        $result = $this->getDbConnection()->getAll($sql, $args);
        return $result;
    }
} 